import { COMMON_PARAMS } from './config'
import jsonp from 'common/js/jsonp'
import axios from 'axios'

export const getRecommend = function () {
  return new Promise(function (resolve, reject) {
    const url = '/api/getSilde'
    axios.get(url)
      .then(function (response) {
        resolve(response);
      })
      .catch(function (err) {
        reject(err);
      });
  });
}

export function getDiscList() {
  const url = '/api/getDiscList'

  const data = Object.assign({}, COMMON_PARAMS, {
    platform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function getSongList(disstid) {
  const url = '/api/getSongList'

  const data = Object.assign({}, COMMON_PARAMS, {
    type: 1,
    json: 1,
    utf8: 1,
    onlysong: 0,
    disstid: disstid,
    format: 'json',
    g_tk: 5381
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}